<?php
namespace app\index\model;
use think\Model;
use app\index\model\Build as Bu;
class Build extends Model
{
	public function list()
	{
		/*$list = self::where('id','>',0)->select();
		return $list;*/
		$list=new build();
		if(!empty(input('param.name'))){
			$list=$list->where("name","like","%".input("param.name/s")."%");	
		}
		$list=$list->paginate(5,false,['query'=>input('param.')]);
		return $list;

	}
	 public function add(){
    $data=[
        'build'=>input("param.build"),
        'b_address'=>input("param.b_address"),
    ];
    $bu = new Build();
    $result = $bu->save($data);
    return $result;
    }
    public function adds($file){
        $info = $file->move( './uploads');
        $infoname=$info->getSaveName();
        $data=[
            'build'=>input("param.build"),
			'b_address'=>input("param.b_address"),
            'image'=>$infoname,
        ];
        $bu = new Build();
        $result = $bu->save($data);
        return $result;
    }
	public function dan(){
        $id= input("param.id");
        $li=self::select($id);
        return $li;
    }
    public function updateById(){
        $bu=new Build();
        $id=input("param.id");
       $data=[
            'build'=>input("param.build"),
			'b_address'=>input("param.b_address"),
            'image'=>$infoname,
        ];
        $resultt=$bu::get($id)->save($data);
        return $resultt;
    }
	 public function deleteById($id)
    {
        /*$cla=self::get($id);
        $result = $cla->delete();
        return $result;
        */
        $result = self::destroy($id);//软删除
        return $result;
    }
}
?>